window.addEventListener('load',function(){
    var items = document.querySelectorAll('.item')
    var jfloors =document.querySelectorAll('.content>.jfloor')
    console.log(jfloors);
    for(let i=0;i<items.length;i++){
        items[i].addEventListener('click',function(){
            for(let i=0;i<items.length;i++){
                items[i].className='item'
            }
            this.className = 'item change'
            console.log(jfloors[i]);
            document.documentElement.scrollTop = jfloors[i].offsetTop
        })

        window.addEventListener('scroll',function(){
            if(document.documentElement.scrollTop >= jfloors[i].offsetTop){
                // console.log(document.querySelector('.change'));
               document.querySelector('.change').classList.remove('change')
                items[i].className = 'item change'
                
            }
            
        })
    
        
    }
    
   
})